I'm coding a program to learn OpenGL in C++ (based off of The Benny Boxes tutorials) and I've run into a snag where I don't get any errors, but my shaders refuse to apply to the triangle that I'm rendering. I'm going to give you all the relevant code but its going to be a lot because, after all, it's OpenGL in C++. display.cpp #include "display.h" #include <GL/glew.h> #include <iostream> Display::Display(int width, int height, const std::string& title) { SDL_Init(SDL_INIT_EVERYTHING); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); m_window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL); m_glContext …

Member Avatar
Member Avatar
+0 forum 2

I've been working with my own system using CPU-managed hitdefs (rectangles for mouse-events) since I didn't want to redraw everything for the gl feedback buffer... (basically I can do all the hitdef position management once during the frame loop) now that modern gl has come into play, I would like to build a better management system that does the event processing asynchronously from the frame using the GPU... but while knowing this is possible, I have no idea where to start and what to research without getting confused... does anyone know the "proper" approach to building a modern asynchronous GPU-based …

Member Avatar
Member Avatar
+0 forum 19

Since OpenGL uses the strange system of 1s and 0s to represent location on the screen, I'm trying to figure out how to switch it to standard x, y coordinates like those that are used on a graph. And so far, my searches on the rest of the internet have turned out nothing. So, to clarify: How do I make it so that the bottom left corner is the starting place of 0,0 instead of the center of the screen, which is where OpenGL Defaults it too? Here is my code for reference: #include <iostream> #include <SDL2/SDL.h> #include <string> #include …

Member Avatar
Member Avatar
+0 forum 1

Hey. I've been working on a home brew game since late last year, writing an engine in Haskell and GLSL that includes 3D graphics, basic physics and programmable game logic. The version in the second video shows the first appearance of lighting and importation of OBJ files (the cube was made in Blender). I'm aiming to do a 3D remake of the game ZZT, a bit like [these guys did with Sonic the Hedgehog](http://www.srb2.org). The game logic can be programmed using a scripting language I made called Game Programmable Logic Controller (GPLC), which allows for the switch and lift interaction …

Member Avatar
+0 forum 0

So I'm maing a 3D game editor in Java using LWJGL (Lightweight Java Game Library), I have the editor set up so that the user can create new levels, load up saved levels, save and quick save current levels, import textured models etc.. the basics. I am now trying to implement a system that when a new model(s) is imported into the editor, a button (JButton) will appear on the bottom taskbar, therefore enabling the user to switch between different models. I am however, having a little trouble. Here is the code which defines the JPanel where I want the …

Member Avatar
Member Avatar
+0 forum 2

I am trying to run the code in openGL in Visual Studio 2013 after installation. It shows error as "Cannot open source file <GL/glew.h> and <GL/glut.h> ". Also it shows "Identifier glutInit is undefined". Can you please resolve this issue ?? #include <GL/glew.h> #include <GL/glut.h> #pragma comment(lib, "glew32.lib") int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitWindowSize(200, 200); glutCreateWindow("Hello"); glutMainLoop(); return 0; }

Member Avatar
Member Avatar
+0 forum 1

on my university I got an assignment to build a program on OpenGl that read from a given txt file a coordinates of some lines and draw them to the screen. i thank everyone that might help me, I know a little bit programming on C but I'm a little confused when it connects with OpenGl. Thanks a lot.

Member Avatar
Member Avatar
+0 forum 1

void PatratTexturat(PATRAT patrat, int numar) { switch(numar) { case 1: if(numar==1) glBindTexture(GL_TEXTURE_2D, id_textura[2]); else glBindTexture(GL_TEXTURE_2D,id_textura[3]); break; case 2: if(numar==2) glBindTexture(GL_TEXTURE_2D, id_textura[4]); else glBindTexture(GL_TEXTURE_2D, id_textura[5]); break; case 3: if(numar==3) glBindTexture(GL_TEXTURE_2D, id_textura[6]); else glBindTexture(GL_TEXTURE_2D, id_textura[7]); case 4: if(numar==4) { glBindTexture(GL_TEXTURE_2D, id_textura[8]); } else { glBindTexture(GL_TEXTURE_2D, id_textura[9]); } break; case 5: glBindTexture(GL_TEXTURE_2D,id_textura[10]); break; case 6: glBindTexture(GL_TEXTURE_2D,id_textura[11]); break; case 7: glBindTexture(GL_TEXTURE_2D,id_textura[12]); break; case 8: glBindTexture(GL_TEXTURE_2D,id_textura[13]); break; case 9: glBindTexture(GL_TEXTURE_2D,id_textura[14]); break; default: glBindTexture(GL_TEXTURE_2D, NULL); break; } glBegin(GL_QUADS); glTexCoord2f(0.0,0.0); glVertex2f(patrat.stanga,patrat.jos); glTexCoord2f(1.0,0.0); glVertex2f(patrat.dreapta,patrat.jos); glTexCoord2f(1.0,1.0); glVertex2f(patrat.dreapta,patrat.sus); glTexCoord2f(0.0,1.0); glVertex2f(patrat.stanga,patrat.sus); glEnd(); } I have the code above and i get the error that `case` may only be used in a …

Member Avatar
Member Avatar
+0 forum 4

void PatratTexturat(PATRAT patrat, int numar) { switch(numar) { case 1: if(numar==1) glBindTexture(GL_TEXTURE_2D, id_textura[2]); else glBindTexture(GL_TEXTURE_2D,id_textura[3]); break; case 2: if(numar==2) glBindTexture(GL_TEXTURE_2D, id_textura[4]); else glBindTexture(GL_TEXTURE_2D, id_textura[5]); break; case 3: if(numar==3) glBindTexture(GL_TEXTURE_2D, id_textura[6]); else glBindTexture(GL_TEXTURE_2D, id_textura[7]); case 4: if(numar==4) { glBindTexture(GL_TEXTURE_2D, id_textura[8]); } else { glBindTexture(GL_TEXTURE_2D, id_textura[9]); } break; case 5: glBindTexture(GL_TEXTURE_2D,id_textura[10]); break; case 6: glBindTexture(GL_TEXTURE_2D,id_textura[11]); break; case 7: glBindTexture(GL_TEXTURE_2D,id_textura[12]); break; case 8: glBindTexture(GL_TEXTURE_2D,id_textura[13]); break; case 9: glBindTexture(GL_TEXTURE_2D,id_textura[14]); break; default: glBindTexture(GL_TEXTURE_2D, NULL); break; } glBegin(GL_QUADS); glTexCoord2f(0.0,0.0); glVertex2f(patrat.stanga,patrat.jos); glTexCoord2f(1.0,0.0); glVertex2f(patrat.dreapta,patrat.jos); glTexCoord2f(1.0,1.0); glVertex2f(patrat.dreapta,patrat.sus); glTexCoord2f(0.0,1.0); glVertex2f(patrat.stanga,patrat.sus); glEnd(); } I have the code above and i get the error that `case` may only be used in a …

Member Avatar
Member Avatar
+0 forum 2

Hi there, i have a ball: [icode] void ball (void) { glColor3f(0.0, 1.0, 0.0); //set ball colour glTranslatef(0.0,0.0,1); //moving it toward the screen a bit on creation glutSolidSphere (0.6, 7, 7); //create ball. } [/icode] I am trying to get the ball to move in a direction when i press the [B]J [/B]key. I attempt this: [icode] void keyboard_s (int key, int x, int y) { switch (key) { case 'j': case 'J': glPushMatrix(); // to save the current matrix glTranslatef(ball.posX += 1, ball.posY, ball.posZ); //move ball +1 on it's x axis ball(); // draw our object glPopMatrix(); // restore …

Member Avatar
Member Avatar
+0 forum 3

Hello everyone, I am trying to write an object loader in c++. Currently, I have a file that is made up of many sub objects and I am having a little difficulty figuring out how to process the data. First of all, here is an example of part of the file o shape_brow_Plane.030 v 3.719171 7.430269 -0.000989 v 3.719171 7.366541 -0.000989 v 3.655808 7.366541 -0.000989 v 3.655808 7.430269 -0.000989 v 3.687490 7.361845 -0.000989 v 3.729859 7.398441 -0.000989 v 3.687490 7.435111 -0.000989 v 3.645120 7.398441 -0.000989 l 28 31 l 29 31 l 27 32 l 28 32 l 27 33 …

Member Avatar
+0 forum 0

Hi, I have a C++ code running OpenGL GUI (CEGUI), I need to wrap this window inside a C# Application. I guess I will compile the C++ as a dll, and add entry points for the C# app. What is the preffered way to do this? I thought of these options: 1. let CEGUI create the window, and pass a handle to C# app (HWND) 2. let C# create the OpenGL context and remove context creation code from CEGUI app ??? Thanks, Yoav

Member Avatar
+0 forum 0

**BREAKOUT GAME IN OPENGL** code is in C. Use the 's' and 'd' to move the paddle. Bounce the ball off the paddle to keep it from falling off the bottom of the screen. Break all the bricks to win. So far the program is running. but the right brick does not disappears when hit by the ball? can u check out my code and tell me whats wrong? what should I do? and also the angles when the ball bounces are not right? what do u thinks causes? what should I do? #include <GL/glut.h> #include <stdlib.h> // LIBRARIES #include …

Member Avatar
Member Avatar
+0 forum 2

Does my old Intel 946GZ Express Chipset Family supports OpenGL 2.0...? Plz reply soon i want to sale it to a minecraft lover...!

Member Avatar
Member Avatar
+0 forum 3

Hello, So I was testing my matrix class and the results look questionable and the inverted matrix isn't returning the vertex to it's original value (a seperate issue). Given a perspective projection at 45 degrees with a near of 1 and a far of 1000, the camera at the orgin looking down z and a vertext along z axis at 0, 1 and 1000, What would their resulting depths be?

Member Avatar
Member Avatar
+0 forum 10

Hello, So I'm aware that OpenGL is Column major and DirectX is Row major, but how does that translate into a basic 1D array? So given the below visual matrix, what would the first 3 in the array of each platform and which 3 would be the x,y and z translation of each platform? |AA BA CA DA| |AB BB CB DB| |AC BC CC DC| |AD BD CD DD| What I'm trying to find out is if I was given a matrix pulled from either platforms, would a formula for one work with the other (x,y,z translation index stay …

Member Avatar
Member Avatar
+0 forum 4

My university's TA helped me setup all the necessary files to run OpenGL on vs 2008 (even though his .cpp and .h files were written in vs2013) yet when I compile the project, it gives me a white window. The same code will display a 3d mouse in the computer lab, so I am very lost. There were no compiling problems. Has anyone ever experienced this before?

Member Avatar
Member Avatar
+0 forum 1

hi everybody! I really need your help here. I am developing a 3D game. so far I have came no further than finishing the 3D engine and print out some basic 3D-models. everything works okay, with exception of a bug, occuring after a couple of minutes of running time. it starts with that everything freezes, and then either I have to use process manager to shut it down, or it goes back to working but this time much slower, and after a couple of second giving the error > Microsoft Visual C++ Runtime Library > Runtime Error > This application …

Member Avatar
Member Avatar
+0 forum 7

I need the way in SDL work with openGL for allow users input String by writing text .

Member Avatar
Member Avatar
+0 forum 1

how to get mouse coordinates when user click by mouse using opengl ?

Member Avatar
Member Avatar
+0 forum 1

I have used sdl_ttf in opengl . but i have this error : error LNK1104: cannot open file 'SDL_ttf.lib' i already have tried to remove the "SDL_ttf.lib" , but it didn't useful. i have trid used : lazyfoo.net for setting up the opengl with sdl pls tell me what must i do ? .

Member Avatar
Member Avatar
+0 forum 2

I need the way for allow users input text by writing , while users input text they see what's they input when user press enter jump for next line and when user end press on button to finish ?

Member Avatar
Member Avatar
+0 forum 8

I've tried lots of times to get this to work but , no luck . the problem is this program shows white screen , and It doesn't display the polygon . Here's the code , take a look : /*Headers*/ #include <GL/glut.h> /*End of headers*/ /* Check Compiler*/ #ifdef __FLAT__ #include <Windows.h> #endif /*End of Check*/ /*Preloaded Functions*/ void myInit(void) { glClearColor(1.0, 1.0, 1.0, 0.0); glShadeModel(GL_FLAT); } void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 0.0, 0.0); glBegin(GL_POLYGON); glVertex2f(0.90 , 0.50); glVertex2f(0.50 , 0.90); glVertex2f(0.10 , 0.50); glVertex2f(0.50 , 0.10); glEnd(); } /*End of preloaded functions*/ int main(int argc, char** argv) { glutInit(&argc, …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to create a simple colored cube using vbo(well it actually a rectangle with z = 0). I am using glew & freeglut. Here my code. #include <GL/glew.h> #include <GL/glut.h> #include <stdio.h> const int g_width = 800; const int g_height = 800; #pragma comment(lib, "glew32.lib") static const GLsizeiptr PositionSize = 8 * 3 * sizeof(GLfloat); static const GLfloat PositionData[] = { -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1 }; static const GLsizeiptr ColorSize = 8 * 3 * sizeof(GLubyte); static const GLubyte …

Member Avatar
Member Avatar
+0 forum 2

Hello, I can get OpenGL to render 3D scenes to the screen, but I want to render them to a pixel array. Basically I want some magical code to fill in the blanks for this code segment: int width=500; int height=500; uint32_t *colours=new uint32_t[width*height]; //Magic code! glBegin(GL_TRIANGLES); //other drawing stuff, preferably no magic here? glEnd(); //Magic code! uint32_t c=*colours;//c should be the top-left pixel rendered by opengl From my research it seems as though I should use a framebuffer object to do this, I am just not sure exactly how they work. Any help?

Member Avatar
Member Avatar
+0 forum 4

Hello, Unfortunately I learnt OpenGL from NeHe tutorials, which means that all of my current methods for OpenGL-ing are extremely deprecated. I tried to find a more up-to-date tutorial, but all they seem to do is teach how to get really complicated stuff out of OpenGL. I just want to know: What is the current method of drawing 3D triangles with either coloured or textured vertices to the screen? I know how to use the simple: glBegin(GL_TRIANGLES); //Draw a colourful triangle: glNormal3f(nx,ny,nz);//where nx,ny,nz are calculated based on the vertices glColour3b(a,b,c);//I usually use a preprocessor to allow my canadian spelling glVertex3f(a,b,c); …

Member Avatar
+0 forum 0

Can someone please help me understand what the glMatrixMode() function does? I've read the API and looked on google but I cannot understand what it does. An anology or example would help. Thanks.

Member Avatar
+0 forum 0

Hello, I am wondering how libraries create graphics contexts in a cross-platform manner. Somehow libraries like SDL create graphical windows seemingly without using the system headers. I know how to set up a window for graphics using Win32API, and how to get input from it using the same. How do I write a program such that it can be executed on any system (linux in particular) without requiring a windows environment? Or would I have to create two versions of my program, one for windows and one for linux?

Member Avatar
Member Avatar
+0 forum 5

i do not find the freeglut.dll file in the freeglut binary package i just downloaded. I cant compile my opengl programs as my compiler says "freeglut.dll is missing from your computer. try reinstalling them.." solutions please.

Member Avatar
Member Avatar
+0 forum 1

I am trying to create a triangle in openGL 2.0 but some some reason background is shows up but no triangle. I am following this tutorial: http://developer.android.com/training/graphics/opengl/environment.html i have the same code as on tutorial but for some reason the triangle is not showing up. may be i missed some thing or i am doing some thing wrong? i have two class. GlRender.java GLTriangle.java i think the problem is in GLTriangle draw method. public class GlRender implements Renderer { private GLTriangle glTriangleObj; private final float[] mModelMatrix = new float[16]; private final float[] mProjectionMatrix = new float[16]; private final float[] mViewMatrix …

Member Avatar
+0 forum 0

The End.