Silverfrost Forums

Welcome to our forums

opengl textures. do anyone have it make working?

9 Nov 2011 2:07 #9199

i'm trying to display a texture from a image created in memory (a checker). what i have wrote is:

		subroutine makeCheckImage()
        common/tex/checkImage
        integer*1 checkImage(64,64,4)
	    integer*4 i, j, c,k
    
   		do i = 1,64
		do j = 1,64
         k=i+64*(j-1)
         c = 100*mod(k,2)
     
         checkImage(i,j,1) =  c;
         checkImage(i,j,2) =  c;
         checkImage(i,j,3) =  c;
         checkImage(i,j,4) =  100;
        enddo
        enddo
		end

        subroutine initForTexture()
        common/tex/checkImage
        integer*1 checkImage(64,64,4)
        integer GL_UNSIGNED_BYTE
        PARAMETER (GL_UNSIGNED_BYTE = z'1401')
        integer*4 GL_RGBA
		PARAMETER (GL_RGBA = z'1908')
        integer*4 GL_TEXTURE_MIN_FILTER
        PARAMETER (GL_TEXTURE_MIN_FILTER = z'2801')
		INTEGER*4 GL_NEAREST
		PARAMETER (GL_NEAREST = z'2600')
		INTEGER*4 GL_TEXTURE_MAG_FILTER
		PARAMETER (GL_TEXTURE_MAG_FILTER = z'2800')
		INTEGER*4 GL_TEXTURE_WRAP_T
		PARAMETER (GL_TEXTURE_WRAP_T = z'2803')
		INTEGER*4 GL_REPEAT
		PARAMETER (GL_REPEAT = z'2901')
		INTEGER*4 GL_TEXTURE_WRAP_S
		PARAMETER (GL_TEXTURE_WRAP_S = z'2802')
		INTEGER*4 GL_TEXTURE_2D
		PARAMETER (GL_TEXTURE_2D = z'0DE1')
		INTEGER*4 GL_UNPACK_ALIGNMENT
		PARAMETER (GL_UNPACK_ALIGNMENT = z'0CF5')
		INTEGER*4 GL_DEPTH_TEST
		PARAMETER (GL_DEPTH_TEST = z'0B71')
		INTEGER*4 GL_FLAT
		PARAMETER (GL_FLAT = z'1D00')
		STDCALL GLENABLE 'glEnable' (VAL)
		STDCALL GLTEXIMAGE2D 
     .   'glTexImage2D' (VAL,VAL,VAL,VAL,VAL,VAL,VAL,VAL,REF)
		STDCALL GLPIXELSTOREI 'glPixelStorei' (VAL,VAL)
		STDCALL GLGENTEXTURES 'glGenTextures' (VAL,REF)
		STDCALL GLBINDTEXTURE 'glBindTexture' (VAL,VAL)
		STDCALL GLCLEARCOLOR 'glClearColor' (VAL,VAL,VAL,VAL)
		STDCALL GLSHADEMODEL 'glShadeModel' (VAL)
		STDCALL GLVERTEX3F 'glVertex3f' (VAL,VAL,VAL)
		STDCALL GLTEXENVF 'glTexEnvf' (VAL,VAL,VAL)
		STDCALL GLBEGIN 'glBegin' (VAL)
		STDCALL GLTEXPARAMETERI 'glTexParameteri' (VAL,VAL,VAL)

        integer texName(1)

        call glClearColor (0.0, 0.0, 0.0, 0.0);
   		call glShadeModel(GL_FLAT);
   		call glEnable(GL_DEPTH_TEST);

   		call makeCheckImage();
   		call glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

		call glGenTextures(1, texName);
 		call glBindTexture(GL_TEXTURE_2D, texName(1));

       call glTexParameteri(GL_TEXTURE_2D, 
     .  GL_TEXTURE_WRAP_S, GL_REPEAT);
       call glTexParameteri(GL_TEXTURE_2D, 
     .  GL_TEXTURE_WRAP_T, GL_REPEAT);
       call glTexParameteri(GL_TEXTURE_2D, 
     .  GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       call glTexParameteri(GL_TEXTURE_2D, 
     .  GL_TEXTURE_MIN_FILTER, GL_NEAREST);

!   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, 
!                0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);
       call glTexImage2D(GL_TEXTURE_2D, 0, 4, 64, 
     .  64, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);
		end

    
9 Nov 2011 2:11 #9200
     subroutine displayTexture
       INTEGER*4 GL_QUADS
	   PARAMETER (GL_QUADS = z'0007')
		INTEGER*4 GL_DECAL
		PARAMETER (GL_DECAL = z'2101')
		INTEGER*4 GL_TEXTURE_ENV_MODE
		PARAMETER (GL_TEXTURE_ENV_MODE = z'2200')
		INTEGER*4 GL_TEXTURE_ENV_COLOR
		PARAMETER (GL_TEXTURE_ENV_COLOR = z'2201')
		INTEGER*4 GL_TEXTURE_ENV
		PARAMETER (GL_TEXTURE_ENV = z'2300')
		INTEGER*4 GL_TEXTURE_2D
		PARAMETER (GL_TEXTURE_2D = z'0DE1')
		STDCALL GLTEXCOORD2F 'glTexCoord2f' (VAL,VAL)
		STDCALL GLDISABLE 'glDisable' (VAL)
		STDCALL GLENABLE 'glEnable' (VAL)
		STDCALL GLTEXIMAGE2D 
     .   'glTexImage2D' (VAL,VAL,VAL,VAL,VAL,VAL,VAL,VAL,REF)
		STDCALL GLPIXELSTOREI 'glPixelStorei' (VAL,VAL)
		STDCALL GLGENTEXTURES 'glGenTextures' (VAL,REF)
		STDCALL GLBINDTEXTURE 'glBindTexture' (VAL,VAL)
		STDCALL GLCLEARCOLOR 'glClearColor' (VAL,VAL,VAL,VAL)
		STDCALL GLSHADEMODEL 'glShadeModel' (VAL)
		STDCALL GLVERTEX3F 'glVertex3f' (VAL,VAL,VAL)
		STDCALL GLTEXENVF 'glTexEnvf' (VAL,VAL,VAL)
		STDCALL GLBEGIN 'glBegin' (VAL)

!   	   call glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
   	   call glEnable(GL_TEXTURE_2D);
   	   call glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
!#ifdef GL_VERSION_1_1
!       glBindTexture(GL_TEXTURE_2D, texName);
!#endif

       call glBegin(GL_QUADS);
      	call glTexCoord2f(0.0, 0.0); 
        call glVertex3f(-2.0, -1.0, -6.0);
      	call glTexCoord2f(0.0, 1.0); 
        call glVertex3f(-2.0, 1.0, -6.0);
      	call glTexCoord2f(1.0, 1.0); 
        call glVertex3f(0.0, 1.0, -6.0);
      	call glTexCoord2f(1.0, 0.0); 
        call glVertex3f(0.0, -1.0, -6.0);

      	call glTexCoord2f(0.0, 0.0); 
        call glVertex3f(1.0, -1.0, -6.0);
      	call glTexCoord2f(0.0, 1.0); 
        call glVertex3f(1.0, 1.0, -6.0);
      	call glTexCoord2f(1.0, 1.0); 
        call glVertex3f(2.41421, 1.0, -1.41);
      	call glTexCoord2f(1.0, 0.0); 
        call glVertex3f(2.41421, -1.0, -1.41);
      	call myglEnd();
!$$$$$$         call myglFlush();
      	call glDisable(GL_TEXTURE_2D);
		end

but what is displayed is a black square i'd like also to load an image from a file and display it. do anyone have made it? thanks

21 Nov 2011 6:24 #9257

Have not done this but would be interested if you will go through the difficulties. Specifically i'm interesting in animated textures and guiding the objects in 3D with the mouse. But generally any new examples are welcome - it is a lot of fun if all goes through on OpenGL in this compiler but it's a hell if not. It needs more people using OpenGL with FTN95.

If anyone rewrite Ne-He tutorial made for many languages and dialects including Intel compilers for FTN95/OpenGL that would be great contribution.

http://nehe.gamedev.net/tutorial/flag_effect_waving_texture/16002/

23 Nov 2011 8:32 #9267

i have made it working in many languages, but not in ftn95, so i'm wondering if i have make something wrong with fortran, or is a bug of the bindings

i hope some silverfrost stuff will answer

29 Nov 2011 6:25 #9316

Can you post the complete demo source code instead of some subs for us and developers to reproduce?

6 Dec 2011 3:40 #9352

Hi have a look at this thread that I started a couple of years ago

https://forums.silverfrost.com/Forum/Topic/1086

I successfully created and used a 1d texture in opengl using silverfrost ( the code is in the thread)

Iit would only work with hardware acceleration switched off though. I think this has got something to do withthe silverfrost opengl implemantation as opengl programs using textures that I've written in other languages will run on the same computer with hardware acceleration on full.

Cheers

Albert

9 Dec 2011 6:48 #9361

Thanks for pointing at the post. Unfortunately compiled this code as-is does not produce anything besides white screen no matter what graphics settings are used (and in both XP and Win7). Can you confirm it still works, the post was 5 years ago. What kind of texture it creates, i do not see any texture graphics file in the code ?

10 Dec 2011 6:34 #9363

Hi Dan,

I just copied and pasted the two files ( from the 3rd and 4th replies) into a new project ( in plato 4.3.0) built it and it ran first time. it shows a triangle laid over with a 1 dimensional texture consisting of 4 colours, dark red, light red, light blue, dark blue. These colours are defined at the top of openglmod in array arrcol.

Please note there are two versions of the code in that thread, the one at the top of the thread doesn't work ( which is why i posted in the first place, it wouldn't work!) I worked further on the problem and found several mistakes which i explain lower down in the thread. The code that works is in the 3rd and 4th replies of that thread.

Please let me know ifyou get it to work. As I stated in the thread it would only work for me if I switched off hardware acceleration. This is one reason that I abandoned silverfrost and compiled all my math routines into a dll, and built a gui using other software.

best

Albert

19 Dec 2011 10:26 #9383

Thanks, Albert. Finally got it working in XP. Weird thing is that it now works at 0% and 20% hardware acceleration, further acceleration stops it. Fun is that in any acceleration be it 0% or 100% mode my other OpenGL stuff works similarly fast.

28 Dec 2011 7:12 #9408

-Do you have by chance FTN95 example with bitmap textures? -Or moving textures (the waving flag is a typical example in OpenGL examples written for other languages)? -And also an example with specular reflection (couldn't make it working). Like those on the surfaces or reflective solids, water etc

Please login to reply.