mrog
This commit is contained in:
parent
f63289903b
commit
56070f31e4
2 changed files with 25 additions and 19 deletions
3
fragment.glsl
Normal file
3
fragment.glsl
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
void main() {
|
||||||
|
gl_FragColor = vec4(1.0,0.0,1.0,1.0);
|
||||||
|
}
|
||||||
41
main.c
41
main.c
|
|
@ -1,5 +1,8 @@
|
||||||
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glext.h>
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
float tanf(float in) {
|
float tanf(float in) {
|
||||||
|
|
@ -32,13 +35,6 @@ void perspective(float fovY, float aspect, float zNear, float zFar, float* matri
|
||||||
void drawCube() {
|
void drawCube() {
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
// Front
|
|
||||||
glColor3f(1, 0, 0);
|
|
||||||
glVertex3f(-1, -1, 1);
|
|
||||||
glVertex3f( 1, -1, 1);
|
|
||||||
glVertex3f( 1, 1, 1);
|
|
||||||
glVertex3f(-1, 1, 1);
|
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
glColor3f(0, 1, 0);
|
glColor3f(0, 1, 0);
|
||||||
glVertex3f(-1, -1, -1);
|
glVertex3f(-1, -1, -1);
|
||||||
|
|
@ -84,6 +80,15 @@ void checkGlError() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *vertex_shader_source = "";
|
||||||
|
|
||||||
|
GLuint create_shader() {
|
||||||
|
GLuint vshader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(vshader, 1, &vertex_shader_source, NULL); // vertex_shader_source is a GLchar* containing glsl shader source code
|
||||||
|
glCompileShader(vshader);
|
||||||
|
return vshader;
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("Good Morning 🍵\n");
|
printf("Good Morning 🍵\n");
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
@ -118,22 +123,20 @@ int main() {
|
||||||
glClearColor(0.1f, 0.1f, 0.1f, 1.0f); // Dark gray background
|
glClearColor(0.1f, 0.1f, 0.1f, 1.0f); // Dark gray background
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
//drawCube();
|
||||||
glLoadIdentity();
|
// Front
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glColor3f(1, 0, 0);
|
||||||
|
glVertex2f(-1, -1);
|
||||||
|
glVertex2f(-1, 1);
|
||||||
|
glVertex2f( 1, 1);
|
||||||
|
glVertex2f( 1, -1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
float proj[16];
|
|
||||||
perspective(60.0f, 800.0f / 600.0f, 1.0f, 100.0f, proj);
|
|
||||||
glLoadMatrixf(proj);
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
glTranslatef(0.0f, 0.0f, -5.0f);
|
|
||||||
glRotatef(angle, 1.0f, 1.0f, 0.0f);
|
|
||||||
|
|
||||||
drawCube();
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
angle += 0.5;
|
angle += 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkGlError();
|
checkGlError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue