glut

How to load a bmp on GLUT to use it as a texture?

别来无恙 提交于 2019-11-27 15:53:26
问题 I've been searching all around for a simple solution to add sprites to my OpenGl GLUT simple moon lander game in c++ and it appears I must use bmp's since they're easiest to load and use them as textures on a rectangle. How exactly can I load the bmp's as textures though? 回答1: Look my simple c implementation function to load texture. GLuint LoadTexture( const char * filename ) { GLuint texture; int width, height; unsigned char * data; FILE * file; file = fopen( filename, "rb" ); if ( file ==

Shader can't be compiled

隐身守侯 提交于 2019-11-27 15:04:16
问题 I'm following book "OpenGL Programming Guide 8th Edition". I just want to run the first program introduced in the book on my Mac. It's Mavericks + Xcode 4.6.1 + Intel HD graphics 4000. So the problem is, the shader can't be compiled. Shader codes: #version 410 core layout(location = 0) in vec4 vPosition; void main() { gl_Position = vPosition; } And the error message is: Shader compilation failed: ERROR: 0:1: '' : version '410' is not supported ERROR: 0:1: '' : syntax error #version ERROR: 0:3

Why does glGetString(GL_VERSION) return null / zero instead of the OpenGL version?

做~自己de王妃 提交于 2019-11-27 14:20:39
I'm on Linux Mint 13 XFCE. My problem is that when I run in terminal the command: glxinfo | grep "OpenGL version" I get the following output: OpenGL version string: 3.3.0 NVIDIA 295.40 But when I run the glGetString(GL_VERSION) in my application then the result is null. Why doesn't this code get the gl_version ? #include <stdio.h> #include <GL/glew.h> #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> #include <GL/glext.h> int main(int argc, char **argv) { glutInit(&argc, argv); glewInit(); printf("OpenGL version supported by this platform (%s): \n", glGetString(GL_VERSION)); }

GLUT exit redefinition error

末鹿安然 提交于 2019-11-27 13:28:59
In my simple OpenGL program I get the following error about exit redefinition: 1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs 1> c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\glut.h(146) : see declaration of 'exit' I'm using Nate Robins' GLUT for Win32 and get this error with Visual Studio 2005 or Visual C++ 2005 (Express Edition). What is the cause of this error and how do I fix it? Cause: The stdlib.h which ships with the recent versions of Visual Studio has a different (and

How do I draw text with GLUT / OpenGL in C++?

南楼画角 提交于 2019-11-27 11:49:39
How do I draw a text string onto the screen using GLUT / OpenGL drawing functions? epatel There are two ways to draw strings with GLUT glutStrokeString will draw text in 3D (source: uwa.edu.au ) and glutBitmapString will draw text facing the user (source: sourceforge.net ) Adam Rosenfield If you don't like the built-in stroke font or bitmap font that comes with GLUT as per epatel's answer , you'll have to roll your own solution. NeHe has some good tutorials (along with fully-working sample code) on this: Lesson 13 - Bitmap Fonts Lesson 14 - Outline Fonts Lesson 15 - Texture-Mapped Outline

Initializing OpenGL without GLUT

不羁岁月 提交于 2019-11-27 10:41:09
every introduction and sample that I can find seems to use GLUT or some other framework to "initialize" OpenGL. Is there a way of initializing OpenGL with just what is available in GL and GLU? If not, then what is GLUT doing that is not possible without it? As luke noted, the code to create and bind the context is specific to each windowing platform. Here are some functions to get you started in terms of initializing OpenGL on specific platforms: Windows (a tutorial is here ) wglCreateContext(hDC) Mac OS X -- OS X has essentially three options: Carbon, Cocoa, and the underlying Core Graphics

Difference between OpenGL files glew.h and gl.h/glu.h

蓝咒 提交于 2019-11-27 09:53:17
问题 I've built an OpenGL program with my glu and gl header files default included in windows 7 professional edition. Now, I've bought a book that describes OpenGL game development. The author of this book said, I have to include the glew header into my project. After I've done this I got some unresolved external symbol errors. So, now I'm really confused. I've worked earlier with glBegin and glEnd statements in my program. Now I've to work with glBindBuffers and glGenBuffer etcetera, but I get

Glut deprecation in Mac OSX 10.9, IDE: QT Creator

爷,独闯天下 提交于 2019-11-27 08:58:15
I was trying to build an opengl program on qt creator, installed on my mac, with osx 10.9. I got several warnings on glut functions about its deprecation in osx10.9, a sample error message is like: 'glutInit' is deprecated: first deprecated in OS X 10.9 [-Wdeprecated-declarations] glutInit(&argc, &argv); ^ I wonder if GLUT.h is not usable anymore in osx10.9? According to some other posts, it is said that as long as we change "OS X Deployment Target" back to OSX10.8, then it works. How to do so in qtcreator? Thank you! You can still use it in 10.9. They're sending you a pretty strong signal

GLUT on OS X with OpenGL 3.2 Core Profile

点点圈 提交于 2019-11-27 08:57:37
Is it possible to use GLUT on OS X Lion or OS X Mountain Lion using core profile (so I can use GLSL 1.50)? Can I use the built in GLUT or do I need to use a third-part library such as FreeGLUT? And is there any simple 'Hello world' applications available for OS X with either an XCode project or a make-file? You need at least Mac OS X Lion (OS X 10.7 or higher) for the basic support of OpenGL 3.2. To use the OpenGL 3.2 Core Profile, just add glutInitDisplayMode(GLUT_3_2_CORE_PROFILE | ... | ...); in your main -function. You can check it by std::printf("%s\n%s\n", glGetString(GL_RENDERER), // e

Using the mouse scrollwheel in GLUT

天涯浪子 提交于 2019-11-27 07:35:07
I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom in and out of a scene? How do I do that? BentFX Freeglut's glutMouseWheelFunc callback is version dependant and not reliable in X. Use standard mouse function and test for buttons 3 and 4. The OpenGlut notes on glutMouseWheelFunc state: Due to lack of information about the mouse, it is impossible to implement this correctly on X at this time. Use of this function limits the portability of your application. (This feature does work on X, just not reliably.) You are encouraged to use the standard, reliable mouse-button