Click here to Skip to main content
15,917,321 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Good winsock library ? Pin
Hans Dietrich6-May-07 20:19
mentorHans Dietrich6-May-07 20:19 
AnswerRe: Good winsock library ? Pin
ThatsAlok16-May-07 19:52
ThatsAlok16-May-07 19:52 
Questionproblem with nested loops Pin
longbowaj6-May-07 10:25
longbowaj6-May-07 10:25 
QuestionRe: problem with nested loops Pin
Mark Salsbery6-May-07 10:28
Mark Salsbery6-May-07 10:28 
AnswerRe: problem with nested loops Pin
longbowaj6-May-07 10:32
longbowaj6-May-07 10:32 
AnswerRe: problem with nested loops Pin
Mark Salsbery6-May-07 10:39
Mark Salsbery6-May-07 10:39 
GeneralRe: problem with nested loops Pin
longbowaj6-May-07 10:45
longbowaj6-May-07 10:45 
GeneralRe: problem with nested loops Pin
#realJSOP7-May-07 1:50
professional#realJSOP7-May-07 1:50 
GeneralRe: problem with nested loops Pin
Mark Salsbery7-May-07 4:19
Mark Salsbery7-May-07 4:19 
QuestionRemove help button from property sheet Pin
Max++6-May-07 8:45
Max++6-May-07 8:45 
AnswerRe: Remove help button from property sheet Pin
Tony Hill6-May-07 8:52
professionalTony Hill6-May-07 8:52 
GeneralRe: Remove help button from property sheet Pin
prasad_som6-May-07 20:36
prasad_som6-May-07 20:36 
Questiondynamic memory Pin
Dj_Lordas6-May-07 8:10
Dj_Lordas6-May-07 8:10 
AnswerRe: dynamic memory Pin
Dj_Lordas6-May-07 8:14
Dj_Lordas6-May-07 8:14 
AnswerRe: dynamic memory Pin
Mark Salsbery6-May-07 10:21
Mark Salsbery6-May-07 10:21 
GeneralRe: dynamic memory Pin
John R. Shaw6-May-07 12:13
John R. Shaw6-May-07 12:13 
GeneralRe: dynamic memory Pin
Mark Salsbery6-May-07 12:14
Mark Salsbery6-May-07 12:14 
GeneralRe: dynamic memory Pin
Dj_Lordas6-May-07 22:13
Dj_Lordas6-May-07 22:13 
GeneralRe: dynamic memory Pin
Dj_Lordas6-May-07 22:38
Dj_Lordas6-May-07 22:38 
GeneralRe: dynamic memory Pin
Mark Salsbery7-May-07 9:57
Mark Salsbery7-May-07 9:57 
Questioninteresting dynamic 2-d array and deleting it Pin
sawerr6-May-07 7:19
sawerr6-May-07 7:19 
QuestionWeb Services Pin
Demian Panello6-May-07 6:07
Demian Panello6-May-07 6:07 
AnswerRe: Web Services Pin
led mike6-May-07 9:11
led mike6-May-07 9:11 
GeneralRe: Web Services Pin
Demian Panello6-May-07 10:35
Demian Panello6-May-07 10:35 
QuestionImporting Textures Pin
outer heaven6-May-07 2:09
outer heaven6-May-07 2:09 
hey everyone. can anyone help me with setting up a texture in visual studio.
heres my code just in case thats the reason why my texture isnt showing up.

thanks everyone!!!Smile | :)

#include <gl glut.h="">
#include <gl glu.h="">
#include <gl glaux.h="">
#include <stdio.h>

GLuint texture;

int width, height;
BYTE * data;
FILE * file;

void changeSize(int w, int h)
{
if(h==0)
h = 1;
float ratio = 1.0*w/h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45, ratio, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 5.0,
0.0, 0.0, -1.0,
0.0f, 1.0f, 0.0f);
}

void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_QUADS);
glTexCoord2d(0.0, 0.0); glVertex3f(-1.0f, -1.0f, 0.0f);
glTexCoord2d(-1.0, 1.0); glVertex3f(-1.0f, 1.0f, 0.0f);
glTexCoord2d( 1.0, 1.0); glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2d( 1.0, -1.0); glVertex3f( 1.0f, -1.0f, 0.0f);
glEnd();
glFlush();
glDisable(GL_TEXTURE_2D);
}
GLuint LoadTextureRAW( const char * filename, int wrap )
{


// open texture data
file = fopen( filename, "rb" );
if ( file == NULL ) return 0;

// read texture data
fread( data, width * height * 3, 1, file );
fclose( file );

// allocate a texture name
glGenTextures( 1, &texture );

// select our current texture
glBindTexture( GL_TEXTURE_2D, texture );

// select modulate to mix texture with color for shading
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

// when texture area is small, bilinear filter the closest mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST );
// when texture area is large, bilinear filter the first mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

// if wrap is true, the texture wraps over at the edges (repeat)
// ... false, the texture ends at the edges (clamp)
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
wrap ? GL_REPEAT : GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
wrap ? GL_REPEAT : GL_CLAMP );

// build our texture mipmaps
gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height,
GL_RGB, GL_UNSIGNED_BYTE, data );


return texture;
}

void FreeTexture(GLuint texture)
{
glDeleteTextures(1, &texture);
}


void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH);
glutInitWindowPosition(100, 100);
glutInitWindowSize(320, 320);
glutCreateWindow("Texure");
glutDisplayFunc(renderScene);
glutReshapeFunc(changeSize);
glutMainLoop();
}Laugh | :laugh: Big Grin | :-D

as a seal i will never insult the constitution, to kill and not to be killed, to die and not to be....died.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.