Click here to Skip to main content
15,902,275 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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.

Questionchanging a process priority from another application Pin
mt_samiei6-May-07 0:36
mt_samiei6-May-07 0:36 
QuestionA tool for automatic renaming Pin
adamshuv6-May-07 0:35
adamshuv6-May-07 0:35 
AnswerRe: A tool for automatic renaming Pin
ThatsAlok16-May-07 19:50
ThatsAlok16-May-07 19:50 
QuestionFunction to clear all Cookies from Internet Explorer? Pin
shareholder7715-May-07 21:51
shareholder7715-May-07 21:51 
AnswerRe: Function to clear all Cookies from Internet Explorer? Pin
ThatsAlok16-May-07 19:50
ThatsAlok16-May-07 19:50 
Questionvzsvsd Pin
suchon_phuong5-May-07 21:07
suchon_phuong5-May-07 21:07 
QuestionRe: vzsvsd Pin
Rajesh R Subramanian5-May-07 21:30
professionalRajesh R Subramanian5-May-07 21:30 
QuestionRe: vzsvsd Pin
Hamid_RT6-May-07 6:38
Hamid_RT6-May-07 6:38 
AnswerRe: vzsvsd Pin
Mark Salsbery6-May-07 14:01
Mark Salsbery6-May-07 14:01 
GeneralRe: vzsvsd Pin
Hamid_RT6-May-07 20:33
Hamid_RT6-May-07 20:33 
GeneralRe: vzsvsd Pin
Mark Salsbery7-May-07 4:16
Mark Salsbery7-May-07 4:16 
GeneralRe: vzsvsd Pin
Hamid_RT7-May-07 9:27
Hamid_RT7-May-07 9:27 
AnswerRe: vzsvsd Pin
ThatsAlok16-May-07 19:47
ThatsAlok16-May-07 19:47 
Questionabout InterLocked functions Pin
HOW WHAT5-May-07 16:45
HOW WHAT5-May-07 16:45 
Questionneed an equivilent to CFile::Write() in MFC Pin
cy163@hotmail.com5-May-07 16:16
cy163@hotmail.com5-May-07 16:16 
AnswerRe: need an equivilent to CFile::Write() in MFC Pin
Mark Salsbery5-May-07 17:38
Mark Salsbery5-May-07 17:38 
GeneralRe: need an equivilent to CFile::Write() in MFC Pin
cy163@hotmail.com5-May-07 18:06
cy163@hotmail.com5-May-07 18:06 

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.